﻿using System.Text;
using System.IO;
using System.ComponentModel;

namespace BizTalkOneService.System
{
    public class DiskInfo
    {
        ///
/// http://msdn.microsoft.com/en-us/library/windows/desktop/aa364937
        ///
        ///A directory on the disk.
        /// If this parameter is NULL, the function uses the root of the current disk.
        /// If this parameter is a UNC name, it must include a trailing backslash.
        /// DiskFreeSpaceEx on success, null on error.
        public static DiskFreeSpaceEx GetDiskFreeSpaceEx(string directoryName)
        {
            ulong freeBytesAvailable;
            ulong totalNumberOfBytes;
            ulong totalNumberOfFreeBytes;
            try
            {
                if (Kernel32Dll.GetDiskFreeSpaceEx(directoryName, out freeBytesAvailable, out totalNumberOfBytes, out totalNumberOfFreeBytes))
                {
                    DiskFreeSpaceEx result = new DiskFreeSpaceEx(directoryName, freeBytesAvailable, totalNumberOfBytes, totalNumberOfFreeBytes);
                    return result;
                }
                else
                    throw new Win32Exception();
            }
            catch
            {
                throw;
            }
        }
    }
}